import ElementUI from 'element-ui';

const copy = function(id){
	const input = document.createElement('input');
	document.body.appendChild(input);
	input.setAttribute('value', id);
	input.select();
	if (document.execCommand('copy')) {
		document.execCommand('copy');
		ElementUI.Message.success('复制成功')
		//成功
	}else{
		ElementUI.Message.error('复制失败')
		//失败
	}
	document.body.removeChild(input);
}

const go = function(url,id) {
	this.$router.push({
		path:url,
		query:{
			id:id
		}
	})
}

const down = function(url,name){
  const a = document.createElement('a');
  a.setAttribute('download',name);
  a.setAttribute('href', url);
  a.click();
}

export {copy,go,down}
